package com.github.data_manage.domain.po

import com.github.data_manage.enum.FundMeetingType
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.Table
import jakarta.validation.constraints.NotNull
import java.time.LocalDateTime

/**
 * 用于记录用户生成会议纪要的操作记录
 * @author chenhainan
 * @since 2025/10/7
 */
@Entity
@Table(name = "fund_meeting_history")
open class FundMeetingHistory {

    companion object {

        fun aiMeetingHistory(fundId: Int, meetingType: FundMeetingType): FundMeetingHistory {
            return FundMeetingHistory().apply {
                this.fundId = fundId
                this.meetingType = meetingType.name
                this.insertBy = "AI"
                this.otter = "AI"
                this.createTime = LocalDateTime.now()
            }
        }

        fun normalMeetingHistory(fundMeeting: FundMeeting): FundMeetingHistory {
            return FundMeetingHistory().apply {
                this.fundId = fundMeeting.fundId
                this.meetingType = fundMeeting.meetingType ?: FundMeetingType.NORMAL.name
                this.insertBy = fundMeeting.insertBy
                this.otter = fundMeeting.otter
                this.createTime = LocalDateTime.now()
            }
        }

    }


    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    open var id: Long? = null

    open var createTime: LocalDateTime? = null

    @NotNull(message = "基金 id不能为空")
    @Column(name = "fund_id", nullable = false)
    open var fundId: Int = 0

    open var insertBy: String? = null

    open var otter: String? = null

    open lateinit var meetingType: String


}